<?php
defined( 'BASEPATH' ) or exit( 'No direct script access allowed' );
class MY_Pagination extends CI_Pagination
{
    public function __construct($params = array())
    {
        $this->CI =& get_instance();
        
        switch ($this->CI->uri->logic_group)
        {
            case 'en' :
                $this->CI->load->language( 'pagination', 'english' );
                break;
            default :
                $this->CI->load->language( 'pagination', 'zh_cn' );
        }
        foreach ( array (
                'first_link',
                'next_link',
                'prev_link',
                'last_link' 
        ) as $key )
        {
            if (($val = $this->CI->lang->line( 'pagination_' . $key )) !== FALSE)
            {
                $this->$key = $val;
            }
        }

        $this->initialize($params);
        log_message('info', 'Pagination Class Initialized');
    }
    public function initialize(array $params = array())
    {
        $this->use_global_url_suffix = true;
        parent::initialize( $params );
        if (! $this->first_url)
        {
            $this->first_url = $this->base_url;
            if ($this->reuse_query_string === TRUE)
            {
                $get = $this->CI->input->get();
                unset( $get['c'], $get['m'], $get[$this->query_string_segment] );
            }
            if (! empty( $get ))
            {
                $this->first_url .= '?' . http_build_query( $get );
            }
        }
        $slen = strlen( $this->suffix );
        if (substr( $this->base_url, - $slen ) === $this->suffix)
        {
            $this->base_url = substr( $this->base_url, 0, - $slen );
        }
        return $this;
    }
}